class LocalCache {
  static instance: LocalCache
  private constructor() {}
  static getInstnace() {
    if (!this.instance) {
      return new LocalCache()
    } else {
      return this.instance
    }
  }
  getCache(key: string): string | undefined {
    const value = localStorage.getItem(key)
    if (value) {
      return JSON.parse(value)
    }
  }

  setCache(key: string, value: any): void {
    localStorage.setItem(key, JSON.stringify(value))
  }

  clearCache() {
    localStorage.clear()
  }

  removeCache(key: string) {
    localStorage.removeItem(key)
  }
}

export default LocalCache.getInstnace()
